package com.itheima.mapper.backend;

import com.itheima.pojo.Permission;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;

import java.util.Set;

/**
 * 用户数据访问接口
 */
@Mapper
public interface UserMapper {

    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_USER')")// 参数必须为对象，否则会报错
    @PostAuthorize("hasAnyAuthority('ROLE_ADMIN','ROLE_USER')")// 返回值必须为对象，否则会报错

    /**
     * 根据用户名查询用户信息
     * @param username
     * @return
     */
    User findByUsername(String username);

    /**
     * 根据角色id查询权限信息
     * @param id
     * @return
     */
    Set<Permission> findPermissionsByRoleId(Integer id);
}
